
使用Spring Security ACL
我试图在我的应用程序中实现Spring Security ACL。我有许多要使用ACL的类。我在文档中读到,以前曾经成功使用过AOP。这是否意味着所有服务都应该具有一个公共接口,以便对对象进行CRUD,以最大程度地重用建议?还是在服务的保存,更新,删除方法中手动插入,删除,…是正常的?我无法找到许多有...
2024-01-10
Spring Security和JSON认证
我在spring / spring-mvc中有一个完全使用JSON通信的应用程序。现在,我需要通过JSON使用Spring Security 3(使用LdapAuthenticationProvider)对我的应用程序进行身份验证。默认的spring seurity提交表单需要这样的POST:POST /myapp/j_spring_security_check HTTP/1.1Accept-Encoding: gzip,deflateContent-Type: application/x-www-form...
2024-01-10
Spring Security在运行时注销用户
我正在实现一个基于Spring的Web应用程序,该应用程序将SpringSecurity与DaoAuthenticationProvider一起使用。为此,我创建了一个具有布尔isEnabled()的User类。方法,因为它实现了SpringsUserDetails接口。因此,如果“未启用”用户,则该用户将无法登录。到目前为止,一切都很好。如果我在运行时仍处于登录状态...
2024-01-10
Spring @Resource处理
我在注解如@ResourceSpring bean中的字段时遇到麻烦。我有的:用setter方法注释的字段 @Resource@Resourceprivate URL someUrl;public void setSomeUrl(URL someUrl) { this.someUrl = someUrl;}<env-entry>我的部署描述符(web.xml)中的标签<env-entry> <env-entry-name>someUrl</env-entry-name> <env-entr...
2024-01-10
Spring Security HTTP基本认证
我正在尝试使用Spring Security做一个非常简单的基本身份验证。我已经正确配置了名称空间,并且服务器中没有异常。在我的“servlet.xml”中,我获得了Spring Security的下一个:<security:http> <security:http-basic></security:http-basic> <security:intercept-url method="POST" pattern="/**" access="ROLE_USER" /></security:htt...
2024-01-10
使用spring security告诉ajax请求登录页面在哪里
我有一些用spring保护的网址(通过xml配置)。有用。但是,当我尝试使用ajax请求到达该端点时,得到了302(找到)响应。这会将我的ajax调用重定向到登录页面(因此我获取html)。但是,我想获得一个401(未经授权)响应,其中包含客户端应用程序可用的登录页面的url,因此我可以使用javascript将用户重...
2024-01-10
正确配置Spring Security OAuth2
我正在尝试使用spring-security-oauth2和jwt配置授权服务器。我的主要:@SpringBootApplication@EnableResourceServerpublic class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); }}我的安全性配置:@Configuration@EnableGlobalM...
2024-01-10
在Spring Security中更改登录服务URL
嗨,我已经在我的Spring Boot Web应用程序中使用JWT过滤器实现了Spring安全性。但是默认身份验证发生在urlhttp://localhost:8080/login。如何更改/login为我需要的某些网址/rest/auth/login?我的WebSecurity课是@EnableWebSecuritypublic class WebSecurity extends WebSecurityConfigurerAdapter {@Autowiredprivate UserDetailsServ...
2024-01-10
Spring Security-身份验证失败-空白消息
我正在研究spring-mvc网络应用程序。在我的登录页面上,如果用户输入了错误的凭据,我想显示一条错误消息。因此,我尝试使用Spring Security来显示错误消息,但无法显示任何消息。对于登录表单,我已将绑定完成为:<form method="post" action="<c:url value='/j_spring_security_check' />" id="loginForm">.... login ui</form>...
2024-01-10
Spring Security-如果已经登录,则重定向
我不希望经过身份验证的用户访问登录页面。如果用户已经通过身份验证,处理“ /登录”重定向的正确方法是什么?说,如果已经登录,我想重定向到“ / index”。我已经在登录时尝试过’isAnonomous()’,但是它重定向到访问被拒绝的页面。<security:http auto-config="true" use-expressions="true" ...> <form-login...
2024-01-10
Spring Data Rest和Cors
我正在开发一个带有Rest接口和一个飞镖的Spring Boot应用程序。XMLHttpRequest确实执行一个OPTIONS请求,该请求的处理完全正确。此后,发出最终的GET(“ / products”)请求,但请求失败:所请求的资源上不存在“ Access-Control-Allow-Origin”标头。因此,不允许访问源’ http:// localhost:63343 ‘。经过一些调试...
2024-01-10
Spring Security hasRole()无法正常工作
我在使用Spring Security &&Thymeleaf时遇到问题,特别是在尝试使用hasRole表达式时。“ admin”用户的角色为“ ADMIN”,但hasRole('ADMIN')无论如何我都会解析为false我的html:1.<div sec:authentication="name"></div> <!-- works fine -->2.<div sec:authentication="principal.authorities"></div> <!-- works fine -->3....
2024-01-10
成功登录后,Spring Security重定向到上一页
我知道之前曾有人问过这个问题,但是我在这里面临一个特殊的问题。我使用Spring Security 3.1.3。我的Web应用程序中有3种可能的登录案例:通过登录页面登录:确定。通过受限页面登录:也可以。通过非受限页面登录:不好,…每个人都可以访问“产品”页面,并且用户可以在登录后发表评论。因此...
2024-01-10
Spring Security:多个HTTP配置不起作用
我正在尝试使用Spring Security,并且有一个用例,其中我想保护不同的登录页面和不同的URL集。这是我的配置:@Configuration@Order(1)public static class ProviderSecurity extends WebSecurityConfigurerAdapter{ @Override protected void configure(HttpSecurity http) throws Exception { http ...
2024-01-10
Spring Security过滤器链不会忽略指定的路径
我有一个通过JWT进行身份验证的Spring Boot REST API。我的问题是,我已将SpringSecurity配置为允许无限制地访问用于身份验证的路径/auth/token,但是当它不应该被访问时,它仍然会击中我的安全过滤器。不知道我在哪里错了,任何建议都非常适合安全配置public class JwtWebSecurityConfig extends WebSecurityConfigurerAdapter...
2024-01-10
Spring MVC-无法获取RequestDispatcher
我的Spring MVC应用程序出现问题。该问题 发生在Linux服务器上,本地(Windows 7 + Eclipse)上,一切正常。当我访问我的页面时, 但是当服务器必须为jsp页面提供服务时,我会得到:HTTP Status 500 - Could not get RequestDispatcher for [/WEB-INF/pages/index.jsp]: Check that the corresponding file exists within your web application...
2024-01-10
使用sortKeys和参数值的Spring Batch分页
我在Spring Boot中运行的SpringBatch项目运行得很好。对于我的读者,我将JdbcPagingItemReader与MySqlPagingQueryProvider一起使用。@Beanpublic ItemReader<Person> reader(DataSource dataSource) { MySqlPagingQueryProvider provider = new MySqlPagingQueryProvider() provider.setSelectClause(...
2024-01-10
在spring@RequestBody始终为空
对于以下方法,JSONObject始终为空。 @RequestMapping(value = "/package/{id}", method = RequestMethod.PUT)@ResponseStatus(HttpStatus.OK)@ResponseBodypublic SPackage updatePackage(@PathVariable String id, @RequestBody JSONObject sPackage) {}我的ajax就是这样 我正在将对象作为服务器端的空映射 ...
2024-01-10
如何从Spring Security获取当前登录的用户对象?
我正在使用Spring安全性版本3.1.4.RELEASE。如何访问当前登录的用户对象?SecurityContextHolder.getContext().getAuthentication().getPrinciple()返回用户名,而不是用户对象。那么,如何使用返回的用户名并获得UserDetails对象?我尝试了以下代码:public UserDetails getLoggedInUser(){ final Authentication auth = SecurityContextHolder...
2024-01-10
Spring Security身份验证问题:HTTP 401
我在使用Spring Security时遇到了一个奇怪的情况。使用过: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> </parent>通过以下简单的安全配置:import org.springframework.beans.f...
2024-01-10
Spring Security HttpSecurity配置
我尝试了解RequestMatcher,AntMatcher等的工作方式。我阅读了一些帖子并了解了基础知识。其实我有这个简单的基本配置:@Overrideprotected void configure(HttpSecurity http) throws Exception { http.requestMatchers() //1 .antMatchers("/login", "/oauth/authorize") //2 .and() //3 .author...
2024-01-10
Spring Security-具有请求参数规则的网址被忽略
我有一个使用Spring Security的Web应用程序。它使用<intercept-url ../>元素描述不同URL的访问过滤器。默认情况下,这不考虑url的请求参数。我需要根据请求参数设置URL的自定义安全规则。所以我做了以下工作:1)我创建了一个bean后处理器类,它将为spring安全机制启用request parameters选项:<beans:beans> . . . ...
2024-01-10
Jersey与Spring MVC的集成
我想创建一个可以与android应用程序一起使用的网站。对于这些其他调用,我想使用单独的servletWeb.xml<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/we...
2024-01-10
Spring Security登录始终落在没有消息的错误页面中
我在Spring的一个小型项目中使用的是登录表单,但是我有一个小问题,那就是每次我使用登录表单登录时都会收到错误重定向。这是我的SecurityConfiguration.javapackage com.ffuentese;import javax.sql.DataSource;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Va...
2024-01-10
使用YAML的Spring @PropertySource
Spring Boot允许我们用YAML等效项替换application.properties文件。但是,我的测试似乎遇到了障碍。如果我对我的注释TestConfiguration(一个简单的Java配置),则需要一个属性文件。例如,这不起作用: @PropertySource(value = "classpath:application-test.yml")如果我的YAML文件中有此文件:db: url: jdbc:oracle:thin:@pathToMyDb user...
2024-01-10
